﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Muccu
{
    public class Compressor
    {
        public static void GZipIfSupportedByClient(HttpRequest request, HttpResponse response)
        {
            string AcceptEncoding = request.Headers["Accept-Encoding"];

            if (AcceptEncoding != null && AcceptEncoding.Contains("gzip"))
            {
                response.Filter = new System.IO.Compression.GZipStream(response.Filter, System.IO.Compression.CompressionMode.Compress);
                response.Headers.Remove("Content-Encoding");
                response.AppendHeader("Content-Encoding", "gzip");
            }
        }

    }
}
